﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sherwood.Security;
using Sherwood.SignOn.Server.Models;
using Sherwood.SignOn.Server.Models.Repositories;
using Sherwood.SignOn;

namespace Sherwood.SignOn.Server.Models.Repositories.InMemory
{
    [Serializable]
    public class UserSessionClientRecord : IUserSessionClientRecord
    {
        public UserSessionClientRecord()
        {
            
        }

        public int Id { get; set; }

        public string ClientSessionId { get; set; }

        public string SignOutUrl {get; set;}

        public virtual IUserSession UserSession
        {
            get
            {
                return InMemoryRepository.UserSessions.GetUserSession(UserSessionId);
            }
            set
            {
                if (value != null)
                {
                    UserSessionId = value.Id;
                    if (value is UserSession)
                    {
                        if (!value.ClientRecords.Contains(this))
                            ((UserSession)value).ClientRecords.Add(this);
                    }
                }
                else
                {
                    UserSessionId = Guid.Empty;
                }
            }
        }

        public Guid UserSessionId { get; set; }

    }
}
